<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <!-- <meta http-equiv="X-UA-Compatible" content="IE=edge"> -->
    <!-- <meta name="viewport" content="width=device-width, initial-scale=1.0"> -->
    <title>react</title>
</head>

<body>
    <!-- 准备好一个容器 -->
    <div class="test"></div>
    <div class="test2"></div>

    <!-- js按顺序引入 -->
    <!-- 引入react核心库 -->
    <script type="text/javascript" src="../js/react.development.js"></script>

    <!-- 引入react-dom,用于操作dom -->
    <script type="text/javascript" src="../js/react-dom.development.js"></script>

    <!-- 引入babel,用于将jsx转为js -->
    <script type="text/javascript" src="../js/babel.min.js"></script>

    <!-- 引入prop-types,用于对组件标签进行限制 -->
    <script type="text/javascript" src="../js/prop-types.js"></script>

    <script type="text/babel">
        // 1.创建类式组件 组件名首字母必须大写
        class Person extends React.Component{        
            render(){
                const {name,sex,age } =this.props
                return (
                    <ul>
                      <li>姓名：{name}</li>  
                      <li>性别：{sex}</li>  
                      <li>年龄：{age}</li>  
                        </ul>
                )
            }
        }
       // 限制类型 string number func 
    Person.propTypes = {
        name:PropTypes.string.isRequired,// 名字为字符类型，必传
        sex:PropTypes.string,
        age:PropTypes.number
    }
    // 设置标签属性默认值
Person.defaultProps = {
sex:'不男不女',
age:20

}
    
      // 2.渲染虚拟Dom 
      ReactDOM.render(<Person name="李文清" sex='男' age={21}    />, document.querySelector(".test"));
      ReactDOM.render(<Person name="李文清"  age={21}    />, document.querySelector(".test2"));
    </script>
</body>
<style>

</style>

</html>